<!-- camera_stream/templates/camera_stream/index.html -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Live Video Stream</title>
</head>
<body>
    <h1>Live Video Stream</h1>
    <img id="live-video" src="{% url 'live_video_feed' %}" alt="Live Video" />
    <button id="toggle-stream">Start</button>

    <script>
        const toggleButton = document.getElementById('toggle-stream');
        let isStreaming = false;

        toggleButton.addEventListener('click', () => {
            if (isStreaming) {
                document.getElementById('live-video').src = '';
                toggleButton.innerText = 'Start';
                isStreaming = false;
            } else {
                document.getElementById('live-video').src = '{% url "live_video_feed" %}';
                toggleButton.innerText = 'Stop';
                isStreaming = true;
            }
        });
    </script>
</body>
</html>
